<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="/godance/layui/src/css/layui.css" rel="stylesheet">
    <script src="/godance/layui/src/layui.js"></script>
    <script src="/godance/js/jquery-3.4.1.js"></script>
    <script src="/godance/js/My_js.js"></script>
    <script type="text/javascript">
        // 表单,依赖 form 模块
        layui.use('form', function() {
            var form = layui.form;
        })
    </script>
</head>
<body>
<form action="" class="layui-form">
    <br/>
    <br/>
    <br/>
    <!-- 基本的行区块结构，它提供了响应式的支持。-->
    <div class="layui-form-item">  <!--这一行-->
        <label class="layui-form-label">收藏夹名</label>  <!--区 -->
        <div class="layui-input-inline">  <!--块 -->
            <!-- 输入框 -->
            <input id="coll_name" type="text" name="title" required lay-verify="required" placeholder="请输入收藏夹的名字" autocomplete="off" class="layui-input" />
        </div>
        <button id="btn11" class="layui-btn layui-btn-normal">确认</button>
    </div>
</form>
</body>
</html>

<script type="text/javascript">
    $(function () {
        $("#btn11").click(function () {
            var token = localStorage.getItem('token');
            $.ajax({
                url:"add_one",
                headers:{
                    "Authorization": "Bearer "+token
                },
                data:{
                    "name":$("#coll_name").val(),
                },
                dataType:"json",
                type:"post",
                success:function (result) {
                    if (result.code==200){
                        alert("创建成功")
                    }else if (result.code==404){
                        alert("已经有相同名称的文件夹")
                    }else {
                        alert("未登录 请登录")
                    }
                }
            })
        })
    })
</script>